#include<bits/stdc++.h>
#define endl '\n'
#define debug(x) cout<<#x<<':'<<x<<endl
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
const int N=25;
int n,k;
vector<int> G[N];
int flag=1;
int bit;
int ans;
void dfs(int x,int fa,int len,int cnt){
    if(!flag) return;
    if(len==k){
        if(cnt!=1) flag=0;
        return;
    }
    for(int y:G[x]){
        if(y==fa) continue;
        if(bit&(1<<(y-1))) dfs(y,x,len+1,cnt+1);
        else dfs(y,x,len+1,cnt);
    }
}
signed main(){
    freopen("life.in","r",stdin);
    freopen("life.out","w",stdout);
    cin>>n>>k;
    if(n>18) return cout<<"YES"<<endl<<k,0;
    for(int i=1,u,v;i<n;i++){
        cin>>u>>v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    for(bit=0;bit<(1<<n);bit++){
        flag=1;
        for(int i=1;i<=n;i++){
            if(bit&(1<<(i-1))) dfs(i,0,1,1);
            else dfs(i,0,1,0);
        }
        ans+=flag;
    }
    if(ans) cout<<"YES";
    else cout<<"NO";
    cout<<endl<<ans;
    return 0;
}